﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using mbhxnaengine.Code.Utilities;

namespace mbhxnaengine.Code.GameObject
{
    // The base object for all elements that make up the game world.
    //
    abstract class GameObject
    {
        
        // The position of the object in the world.  In the case of a 2D
        // element, the Z component will be ignored.
        //
        protected Vector3 mPosition;

        // The pitch, yaw and roll of the object in the world.  In the case
        // of a 2D element, the rotation will be based around the Z axis (roll).
        //
        protected Vector3 mRotation;
        
        // The scale of the object, with 1.0 being equal to it's orginal value.
        //
        protected float mScale;

        // HACK:
        //      Adding this to get the line GOLine working which needs a handle to the graphics
        //      device.  Need to create a rendering manager to store stuff like this so we don't
        //      need to keep passing it around everywhere.
        //
        public static GraphicsDevice mGraphics;

        // Constructor
        //
        public GameObject()
        {
            mPosition = Vector3.Zero;
            mRotation = Vector3.Zero;
            mScale = 1.0f;

            DebugMessageDisplay.pInstance.AddConstantMessage("Game Object Added");
        }

        // Called once, when the object is loaded.
        //
        public abstract void LoadContent(String fileName);

        // Called every frame.
        //
        public abstract void Update(GameTime gameTime);

        // Called at the end of every frame.
        //
        public abstract void Render(SpriteBatch batch);

        // Accessor of pPopsition property.
        //
        public Vector3 pPosition
        {
            get
            {
                return mPosition;
            }
            set
            {
                mPosition.X = value.X;
                mPosition.Y = value.Y;
                mPosition.Z = value.Z;
            }
        }

        // Accessor of pScale property.
        //
        public float pScale
        {
            get
            {
                return mScale;
            }
            set
            {
                mScale = value;
            }
        }

        // Accessor of pRotation property.
        //
        public float pRotation
        {
            get
            {
                return mRotation.Z;
            }
            set
            {
                //mRotation.X = value.X;
                //mRotation.Y = value.Y;
                mRotation.Z = value;
            }
        }
    }
}
